using System;
using System.Collections.Generic;
using System.Text;

using System.Data;
using Husb.Data;
using Husb.Util;
using CentralOffice.Enterprise.Data;
using CentralOffice.Enterprise.DataAccess;
using ReceiverTable = CentralOffice.Enterprise.Data.NoticeReceiverDataSet.NoticeReceiverDataTable;
using ReceiverRow = CentralOffice.Enterprise.Data.NoticeReceiverDataSet.NoticeReceiverRow;


namespace CentralOffice.Enterprise.BusinessActions
{
    public class NoticeReceiver : DataAccessManager<NoticeReceiverDataSet, ReceiverTable, ReceiverRow, NoticeReceiverAdapter>
    {
        public static ReceiverTable FetchByNoticeId(string id, bool isApproved)
        {
            NoticeReceiverAdapter adapter = new NoticeReceiverAdapter();
            return adapter.FetchByNoticeId(new Guid(id), isApproved );
        }

        public static ReceiverTable FetchByNoticeId(string id)
        {
            return FetchByNoticeId(id, false);
        }

        public static ReceiverTable FetchByEnterpriseId(string id, bool isApproved)
        {
            if (string.IsNullOrEmpty(id) || id.Length < 32) return null;
            NoticeReceiverAdapter adapter = new NoticeReceiverAdapter();
            return adapter.FetchByEnterpriseId(new Guid(id), isApproved);
        }

        public static ReceiverTable FetchByEnterpriseId(string id)
        {
            return FetchByEnterpriseId(id, false);
        }

        public static int ReplyNotice(string id, string approvedBy, DateTime approvedDate, string approvedText, bool isApproved)
        {
            NoticeReceiverAdapter adapter = new NoticeReceiverAdapter();
            return adapter.ReplyNotice(new Guid(id), approvedBy, approvedDate, approvedText, isApproved);
        }

        public static int FetchNoticeCountByEnterpriseId(Guid enterpriseId, bool isApproved)
        {
            NoticeReceiverAdapter adapter = new NoticeReceiverAdapter();
            return adapter.FetchNoticeCountByEnterpriseId(enterpriseId, isApproved);
        }

        public static ReceiverRow FetchById(Guid enterpriseId, Guid noticeId)
        {
            NoticeReceiverAdapter adapter = new NoticeReceiverAdapter();
            return adapter.FetchById(enterpriseId, noticeId);
        }
    }
}
